home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / OS2 / DIKUMUD.ZIP / SOUND.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  2.7 KB  |  127 lines

  1. /*
  2.   SillyMUD Distribution V1.1b             (c) 1993 SillyMUD Developement
  3.  
  4.   See license.doc for distribution terms.   SillyMUD is based on DIKUMUD
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. #include "protos.h"
  11.  
  12. /* extern variables */
  13.  
  14. extern struct obj_data *object_list;
  15. extern struct char_data *character_list;
  16.  
  17. int RecGetObjRoom(struct obj_data *obj) 
  18. {
  19.   if (obj->in_room != NOWHERE) {
  20.     return(obj->in_room);
  21.   }
  22.   if (obj->carried_by) {
  23.     return(obj->carried_by->in_room);
  24.   }
  25.   if (obj->equipped_by) {
  26.     return(obj->equipped_by->in_room);
  27.   }
  28.   if (obj->in_obj) {
  29.     return(RecGetObjRoom(obj->in_obj));
  30.   }
  31. }
  32.  
  33. void MakeNoise(int room, char *local_snd, char *distant_snd)
  34. {
  35.   int door;
  36.   struct char_data *ch;
  37.   struct room_data *rp, *orp;
  38.   
  39.   rp = real_roomp(room);
  40.   
  41.   if (rp) {
  42.     for (ch = rp->people; ch; ch = ch->next_in_room) {
  43.       if (!IS_NPC(ch) && (!IS_AFFECTED(ch, AFF_SILENCE))) {
  44.          send_to_char(local_snd, ch);
  45.       }
  46.     }
  47.     for (door = 0; door <= 5; door++) {
  48.       if (rp->dir_option[door] &&
  49.       (orp = real_roomp(rp->dir_option[door]->to_room)) ) {
  50.     for (ch = orp->people; ch; ch = ch->next_in_room) {
  51.       if (!IS_NPC(ch) && (!IS_SET(ch->specials.act, PLR_DEAF)) &&
  52.           (!IS_AFFECTED(ch, AFF_SILENCE))) {
  53.             send_to_char(distant_snd, ch);
  54.       }
  55.     }
  56.       }
  57.     }
  58.   }
  59. }
  60.  
  61. MakeSound(int pulse)
  62. {
  63.   int room;
  64.   char buffer[128];
  65.   struct obj_data *obj;
  66.   struct char_data *ch;
  67.  
  68. /*
  69.  *  objects
  70.  */
  71.   
  72.   for (obj = object_list; obj; obj = obj->next) {
  73.     if (ITEM_TYPE(obj) == ITEM_AUDIO) {
  74.       if (((obj->obj_flags.value[0]) && 
  75.        (pulse % obj->obj_flags.value[0])==0) ||
  76.       (!number(0,5))) {
  77.     if (obj->carried_by) {
  78.       room = obj->carried_by->in_room;
  79.     } else if (obj->equipped_by) {
  80.       room = obj->equipped_by->in_room;
  81.     } else if (obj->in_room != NOWHERE) {
  82.       room = obj->in_room;
  83.     } else {
  84.       room = RecGetObjRoom(obj);
  85.     }
  86.     /*
  87.      *  broadcast to room
  88.      */
  89.     
  90.     if (obj->action_description) {      
  91.       MakeNoise(room, obj->action_description, obj->action_description);
  92.     }
  93.       }
  94.     }
  95.   }
  96.  
  97. /*
  98.  *   mobiles
  99.  */
  100.  
  101.   for (ch = character_list; ch; ch = ch->next) {
  102.     if (IS_NPC(ch) && (ch->player.sounds) && (number(0,5)==0)) {
  103.       if (ch->specials.default_pos > POSITION_SLEEPING) {
  104.     if (GET_POS(ch) > POSITION_SLEEPING) {
  105.       /*
  106.        *  Make the sound;
  107.        */
  108.       MakeNoise(ch->in_room, ch->player.sounds, ch->player.distant_snds);
  109.     } else if (GET_POS(ch) == POSITION_SLEEPING) {
  110.       /*
  111.        * snore 
  112.        */     
  113.       sprintf(buffer, "%s snores loudly.\n\r", ch->player.short_descr);
  114.       MakeNoise(ch->in_room, buffer, "You hear a loud snore nearby.\n\r");
  115.     }
  116.       } else if (GET_POS(ch) == ch->specials.default_pos) {
  117.     /*
  118.      * Make the sound
  119.      */       
  120.     MakeNoise(ch->in_room, ch->player.sounds, ch->player.distant_snds);
  121.       }
  122.     }
  123.   }
  124. }
  125.  
  126.  
  127.